package com.tedu.user.service.impl;

import com.tedu.user.mapper.UserMapper;
import com.tedu.user.pojo.dto.UserQuery;
import com.tedu.user.pojo.vo.UserViolationRecordVO;
import com.tedu.user.pojo.entity.User;
import com.tedu.user.pojo.vo.UserInfoVO;
import com.tedu.user.service.UserService;
import com.tedu.violation.service.ViolationRecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
@Slf4j
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Autowired
    private ViolationRecordService violationRecordService;

    @Override
    public List<UserInfoVO> selectUserInfo(UserQuery userQuery) {
        log.debug("查询用户信息业务-入参：{}", userQuery);
        List<UserInfoVO> list = userMapper.selectUserInfo(userQuery);
        return list;
    }

    @Override
    public void updateStatus(Integer userId, String status) {
        log.debug("查询用户信息业务-入参：{}，{}", userId, status);
        User user = new User();
        user.setUserId(userId);
        user.setStatus(status);
        user.setUpdateTime(new Date());
        userMapper.updateStatus(user);
    }

    @Override
    public List<UserViolationRecordVO> selectViolationRecordByUserId(Integer userId) {
        log.debug("查看违规详情业务-入参：{}", userId);
        return violationRecordService.selectViolationRecordByUserId(userId);
    }
}
